from datetime import datetime

from exts import db


class BookModel(db.Model):
    __tablename__='book'
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    name = db.Column(db.String(20),nullable=False)
    create_time = db.Column(db.DateTime,default=datetime.now)
    is_active = db.Column(db.Boolean,default=True)
    author_name = db.Column(db.String(30))
    board_id = db.Column(db.Integer,db.ForeignKey("board.id"),nullable=False)
    desc = db.Column(db.Text)
    is_borrowed = db.Column(db.Boolean,default=0,nullable=False)
    board = db.relationship('BoardModel',backref='books')


class BoardModel(db.Model):
    __tablename__ = 'board'
    id = db.Column(db.Integer,primary_key=True,autoincrement=True)
    name = db.Column(db.String(20),nullable=False)
    create_time = db.Column(db.DateTime,default=datetime.now)
    is_active = db.Column(db.Boolean, default=True)

